package com.example.personalizededucationsystem.dto.dto;

import com.example.personalizededucationsystem.model.AssignmentQuestion;
import com.example.personalizededucationsystem.model.Question;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class QuestionInAssignmentDto {
    private Long questionId;
    private String content;
    private Question.QuestionType type;
    private String options;
    private int order;

    public static QuestionInAssignmentDto fromEntity(AssignmentQuestion aq) {
        QuestionInAssignmentDto dto = new QuestionInAssignmentDto();
        Question question = aq.getQuestion();
        if (question != null) {
            dto.setQuestionId(question.getQuestionId());
            dto.setContent(question.getContent());
            dto.setType(question.getType());
            dto.setOptions(question.getOptions());
        }
        dto.setOrder(aq.getQuestionOrder());
        return dto;
    }

}